<?php

/**
 * 考点 API
 * User: don
 */

namespace app\modules\app\controllers;

use yii;
use app\libs\AppControl;
use app\libs\Method;
use app\libs\Pager;
use app\libs\VerificationCode;
use app\libs\Sms;
use app\modules\content\models\Examroom;

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: X-Requested-With');
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');

class ExamroomController extends AppControl
{

    public $enableCsrfValidation = false;

    function init (){
        parent::init();
        include_once($_SERVER['DOCUMENT_ROOT'].'/../libs/ucenter/ucenter.php');
    }

    /**
     * [actionIeltsInfo 考点列表]
     * @Author don
     * @Date   2021-10-26
     * @return [type]     [description]
     */
    public function actionList()
    {
        $area = Yii::$app->request->post('area', 0); // 0全部 1华东2华南3华中4华北5西北6西南7东北
        $data = Examroom::getExamroomByArea($area);

        if (empty($data)) {
            die(json_encode(['code'=>0, 'message'=>'未找到区域考点信息！']));
        }

        die(json_encode(['code'=>1, 'data'=>$data]));
    }
    
    /**
     * [actionIeltsInfoDetail 考点详情]
     * @Author don
     * @Date   2021-10-26
     * @return [type]     [description]
     */
    public function actionDetail()
    {
        $city = Yii::$app->request->post('city', '上海');
        $data = Examroom::getExamroomByCity($city);
        if (empty($data)) {
            die(json_encode(['code'=>0, 'message'=>'未找该区域考点详情！']));
        }
        die(json_encode(['code'=>1, 'data'=>$data]));
    }
}
